# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html


import sqlite3
from datetime import date

from finance.db.DBStock import DBStock

class FinancePipeline(object):
    def process_item(self, item, spider):
        return item


class HisStockPopeline(object):	
	def __init__(self):
		self.db = sqlite3.connect("./finance.db")
		self.db_stock = DBStock(self.db)	
	

	def process_item(self, item, spider):		
		if item is None:
			return None
		if item['item_type'] == "his_stock":
			self.db_stock.save_his_stock(item)
		if item['item_type'] == "stock_classify":
			self.db_stock.save_stock_classify(item)